package org.mogoo.haydn.tools;

import java.sql.*;

public class ConnDB
{
	private Connection connection = null;
	
	public Connection getConn()
	{
		try
		{
			Class.forName("org.postgresql.Driver").newInstance();
		   	String url = "jdbc:postgresql://localhost:5432/haydn_project" ;
		   	connection = DriverManager.getConnection(url, "postgres" , "125811" );
	   	}
	   	catch (Exception e)
	   	{
	   		e.printStackTrace();
	   	}
	   	finally
	   	{
	   		
	   	}
		return connection;
	}
	
	public static void  releaseConnection( Connection c)
	{
		if(c != null)
		{
			try
			{
				c.close();
			}
			catch (SQLException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	/**************************************************************************************************************************/
	
	public Connection getConnSpatial()
	{
		try
		{
			Class.forName("org.postgresql.Driver").newInstance();
		   	String url = "jdbc:postgresql://localhost:5432/postgis" ;
		   	connection = DriverManager.getConnection(url, "postgres" , "125811" );
	   	}
	   	catch (Exception e)
	   	{
	   		e.printStackTrace();
	   	}
	   	finally
	   	{
	   		
	   	}
		return connection;
	}
	
	public static void  releaseConnectionSpatial( Connection c)
	{
		if(c != null)
		{
			try
			{
				c.close();
			}
			catch (SQLException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
}
